package me.zhengjie.modules.finace_taxation.service.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import me.zhengjie.base.CommonMapper;
import me.zhengjie.modules.finace_taxation.domain.FtIndustryDetails;
import me.zhengjie.modules.finace_taxation.domain.FtIndustryDetailsFavorite;
import me.zhengjie.modules.finace_taxation.service.dto.FtIndustryDetailsFavoriteDto;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
* @author 杨荣森
* @date 2021-06-23
*/
@Repository
public interface FtIndustryDetailsFavoriteMapper extends CommonMapper<FtIndustryDetailsFavorite> {

    List<FtIndustryDetails> queryByUserId(Page page, Map<String, Object> map);

    /*判断是否收藏过改行业详情*/
    @Select("select count(*) from ft_industry_details_favorite where user_id = #{userId} and industry_details_id = #{industryDetailsId}")
    int industryFavoriteFlag(FtIndustryDetailsFavoriteDto ftIndustryDetailsFavoriteDto);

    /*取消收藏*/
    @Delete("delete from ft_industry_details_favorite where user_id = #{userId} and industry_details_id = #{industryDetailsId}")
    int cacelIndustryFavorite(FtIndustryDetailsFavoriteDto ftIndustryDetailsFavoriteDto);

    /*收藏行业详情*/
    @Insert("insert into ft_industry_details_favorite (id,user_id,industry_details_id) values (replace(uuid(),'-',''),#{userId},#{industryDetailsId})")
    int addIndustryFavorite(FtIndustryDetailsFavoriteDto ftIndustryDetailsFavoriteDto);
}
